package model

import (
	"fmt"
	"jsjb/connect"
)

type AuthOrgAccess struct {
	Adminid int32
	Orgid   int32 `json:"orgid"`
}

func (AuthOrgAccess) TableName() string {
	return "auth_org_access"
}
func BatchCreateAuthOrgAccess(aoa []AuthOrgAccess) (err error) {
	fmt.Printf("aoas%#v\n", aoa)
	results := connect.DB.Create(&aoa)
	err = results.Error
	return
}

func CreateAuthOrgAccess(aoa AuthOrgAccess) (err error) {
	fmt.Printf("aoa%#v\n", aoa)
	results := connect.DB.Create(&aoa)
	err = results.Error
	return
}

func BatchUpdateAuthOrgAccess(aoa []AuthOrgAccess) (err error) {
	result := connect.DB.Table("auth_org_access").Updates(aoa)
	err = result.Error
	return
}

func UpdateAuthOrgAccess(aoa AuthOrgAccess) (err error) {
	result := connect.DB.Model(&aoa).Where("adminid = ? and orgid = ?", aoa.Adminid, aoa.Orgid).Updates(aoa)
	err = result.Error
	return
}
func BatchDeleteAuthOrgAccess(adminIds []int32) (err error) {
	result := connect.DB.Where("adminid IN ?", adminIds).Delete(&AuthOrgAccess{})
	err = result.Error
	return
}
func DeleteAuthOrgAccess(adminId int32) (err error) {
	results := connect.DB.Where("adminid = ?", adminId).Delete(&AuthOrgAccess{})
	err = results.Error
	return
}
